package com.zhouxiaoge.zuul;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;

/**
 * @author 周明阳
 * @date 2019/5/8 09:15
 */

@SpringBootApplication
@EnableZuulProxy
public class Zuul_9004 {
    public static void main(String[] args) {
        SpringApplication.run(Zuul_9004.class, args);
    }

    /**
     * 访问serviceId: user-provider-v1
     * 访问地址 http://localhost:9004/v1/user-provider/simple/1
     */
    @Bean
    public PatternServiceRouteMapper serviceRouteMapper() {
        return new PatternServiceRouteMapper("(?<name>^.+)-(?<version>v.+$)", "${version}/${name}");
    }
}
